package wwk.com.android_meilishuo.ui.secondfloor;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;


import com.wwk.core.utils.ToastUtils;

import wwk.com.android_meilishuo.R;
import wwk.com.android_meilishuo.mvp.presenter.SFPresenter;
import wwk.com.android_meilishuo.mvp.view.MLSView;

public class SecondFloorActivity extends AppCompatActivity implements MLSView.ISecondFloorView {

    private Context mContext = this;
    //纵向viewPager
    private VerticalViewPager verticalViewPager;
    private EmptyLayout sf_EmptyLayout;
    private SFPresenter sfPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second_floor);
        initView();
    }


    private void initView() {

        verticalViewPager = (VerticalViewPager) findViewById(R.id.verticalViewPager_second_floor);
        sf_EmptyLayout = (EmptyLayout) findViewById(R.id.sf_EmptyLayout);
        //verticalViewPager.setOffscreenPageLimit(0);
        sfPresenter = new SFPresenter(this);
        sfPresenter.loadSFData(mContext, sf_EmptyLayout);
        //无网络时点击
        sf_EmptyLayout.setOnLayoutClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                sfPresenter.loadSFData(mContext, sf_EmptyLayout);
            }
        });
    }

    @Override
    public void toSetAdapter(MyVerticalViewPagerAdapter viewPagerAdapter) {
        if (viewPagerAdapter != null) {
            verticalViewPager.setAdapter(viewPagerAdapter);
        }

    }


    @Override
    public void showError(Exception e) {
        ToastUtils.show(e.getMessage());
    }

}
